﻿<%@ Page Title="" Language="C#" MasterPageFile="/Common/Master.master" %>

<script runat="server">

</script>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentForm" runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentHtml" runat="Server">
    <div class="easyui-layout tableEdit" data-options="fit:true,border:false">
        <div data-options="region:'center',border:false" id="validation" class="validationEngineContainer">
            <div class="z_wrap">
                <ul class="info">
                    <li>
                        <em class='l_name'>父标识：</em>
                        <div class='r_con1'>
                            <input id='PID' name='PID' type='text' class='validate[required]' data-prompt-position='bottomRight' />
                        </div>
                    </li>
                    <li>
                        <em class='l_name'>级别：</em>
                        <div class='r_con1'>
                            <input id='Grade' name='Grade' type='text' class='validate[required]' data-prompt-position='bottomRight' />
                        </div>
                    </li>
                    <li>
                        <em class='l_name'>层次：</em>
                        <div class='r_con1'>
                            <input id='Levels' name='Levels' type='text' class='validate[required]' data-prompt-position='bottomRight' />
                        </div>
                    </li>
                    <li>
                        <em class='l_name'>叶子：</em>
                        <div class='r_con1'>
                            <input id='Leaf' name='Leaf' type='text' class='validate[required]' data-prompt-position='bottomRight' />
                        </div>
                    </li>
                    <li>
                        <em class='l_name'>状态：</em>
                        <div class='r_con1'>
                            <input id='State' name='State' type='text' class='validate[required]' data-prompt-position='bottomRight' />
                        </div>
                    </li>
                    <li>
                        <em class='l_name'>禁用：</em>
                        <div class='r_con1'>
                            <input id='Disable' name='Disable' type='text' class='validate[required]' data-prompt-position='bottomRight' />
                        </div>
                    </li>
                    <li>
                        <em class='l_name'>地址：</em>
                        <div class='r_con1'>
                            <input id='Url' name='Url' type='text' class='validate[required]' data-prompt-position='bottomRight' />
                        </div>
                    </li>
                    <li>
                        <em class='l_name'>目标：</em>
                        <div class='r_con1'>
                            <input id='Target' name='Target' type='text' class='validate[required]' data-prompt-position='bottomRight' />
                        </div>
                    </li>
                    <li>
                        <em class='l_name'>图标：</em>
                        <div class='r_con1'>
                            <input id='Icos' name='Icos' type='text' class='validate[required]' data-prompt-position='bottomRight' />
                        </div>
                    </li>
                    <li>
                        <em class='l_name'>类型名称：</em>
                        <div class='r_con1'>
                            <input id='Name' name='Name' type='text' class='validate[required]' data-prompt-position='bottomRight' />
                        </div>
                    </li>
                    <li>
                        <em class='l_name'>内容：</em>
                        <div class='r_con1'>
                            <input id='Contents' name='Contents' type='text' class='validate[required]' data-prompt-position='bottomRight' />
                        </div>
                    </li>
                    <li>
                        <em class='l_name'>创建时间：</em>
                        <div id='AddTime' class='r_con1'>自动</div>
                    </li>
                </ul>
            </div>
        </div>
        <div data-options="region:'south'" style="height: 35px; border-bottom: 0px; border-left: 0px; border-right: 0px;" class="edit_bottom">
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-save'" id="buttonOk">确 定</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="$.layerClose(false);">取 消</a>
        </div>
    </div>

    <script type="text/javascript">
        $(function () {
            jQuery('#validation').validationEngine();

            $("#buttonOk").click(function () {
                InsertOrUpdate();
            });
            if ($.getUrlParamer("guid") != "") {
                DataBind();
            }
        });

        function DataBind() {
            $.InvokeAjax({
                url: "Api/V1/System_Api/GetApi",
                data: { ID: $.getUrlParamer("guid") },
                callBack: function (data) {
                    var obj = $.StrToJson(data).Results;

                    $.SetValue("ID", obj.ID);
$.SetValue("PID", obj.PID);
$.SetValue("Grade", obj.Grade);
$.SetValue("Levels", obj.Levels);
$.SetValue("Leaf", obj.Leaf);
$.SetValue("State", obj.State);
$.SetValue("Disable", obj.Disable);
$.SetValue("Url", obj.Url);
$.SetValue("Target", obj.Target);
$.SetValue("Icos", obj.Icos);
$.SetValue("Name", obj.Name);
$.SetValue("Contents", obj.Contents);
$.SetValue("AddTime", $.DateFormat(obj.AddTime, 'yyyy-MM-dd HH:mm:ss'));
 
                }
            });
        }

        function InsertOrUpdate() {
            if (!$('#validation').validationEngine('validate')) { return false; }            
            var url = $.getUrlParamer("guid") != "" ? "Api/V1/System_Api/UpdateApi" : "Api/V1/System_Api/AddApi";

			var obj = { ID: $.getUrlParamer("guid") };
            obj.PID = $.GetValue("PID");
obj.Grade = $.GetValue("Grade");
obj.Levels = $.GetValue("Levels");
obj.Leaf = $.GetValue("Leaf");
obj.State = $.GetValue("State");
obj.Disable = $.GetValue("Disable");
obj.Url = $.GetValue("Url");
obj.Target = $.GetValue("Target");
obj.Icos = $.GetValue("Icos");
obj.Name = $.GetValue("Name");
obj.Contents = $.GetValue("Contents");
obj.AddTime = $.JsonDateFy($.GetValue("AddTime") == "自动" ? $.GetDateTime() : $.GetValue("AddTime"));


            $.InvokeAjax({
                url: url,
                data: obj,
                callBack: function (data) {
                    $.layerClose(true);
                }
            });
        }
    </script>
</asp:Content>
